Saving file in tkinter not getting saved properly